package com.example.function.sys.controller;

import com.example.common.support.AjaxResponse;
import com.example.common.support.CP_GlobalNamingConstant;
import com.example.common.support.CP_OperateLog;
import com.example.function.sys.model.one.SysDepartment;
import com.example.function.sys.model.pojo.SysDepartmentUsersPojo;
import com.example.function.sys.service.ISysDepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <h1>部门controller</h1>
 * Created by hanqf on 2021/7/22 14:21.
 */

@RestController
public class SysDepartmentController {

    @Autowired
    private ISysDepartmentService sysDepartmentService;

    @RequestMapping(value = "/sys/department_users")
    @CP_OperateLog(value = "部门用户分组查询", type = CP_GlobalNamingConstant.OPERATE_LIST)
    public AjaxResponse department_users() {
        final List<SysDepartmentUsersPojo> allDepartmentUsers = sysDepartmentService.findAllDepartmentUsers();
        return AjaxResponse.success(allDepartmentUsers);
    }

    @RequestMapping(value = "/sys/departments")
    @CP_OperateLog(value = "部门查询", type = CP_GlobalNamingConstant.OPERATE_LIST)
    public AjaxResponse departments() {
        final List<SysDepartment> sysDepartmentList = sysDepartmentService.findAll();
        return AjaxResponse.success(sysDepartmentList);
    }
}
